package com.erps.CommonUtils;

import cn.jpush.api.ErrorCodeEnum;
import cn.jpush.api.JPushClient;
import cn.jpush.api.MessageResult;

public class pushservice {
	public void init() {
		/*
		 * // 对android和ios设备发送 JPushClient jpush = new JPushClient(masterSecret,
		 * appKey); // 对android和ios设备发送,同时指定离线消息保存时间 JPushClient jpush = new
		 * JPushClient(masterSecret, appKey, timeToLive); // 指定某种设备发送 //
		 * JPushClient jpush = new JPushClient(masterSecret, appKey, //
		 * DeviceEnum.Android); // 指定某种设备发送，并且指定离线消息保存时间 JPushClient jpush = new
		 * JPushClient(masterSecret, appKey, timeToLive, DeviceEnum.IOS);
		 */
	}

	public void push() {
		String masterSecret = "";
		String appKey = "";
		JPushClient jpush = new JPushClient(masterSecret, appKey);
		// jpush.setEnableSSL(true);
		int sendNo = 1;
		String imei = "";
		String msgTitle = "";
		String msgContent = "";

		MessageResult msgResult = jpush.sendNotificationWithImei(sendNo, imei, msgTitle, msgContent);
		if (null != msgResult) {
			if (msgResult.getErrcode() == ErrorCodeEnum.NOERROR.value()) {
				System.out.println("发送成功， sendNo=" + msgResult.getSendno());
			} else {
				System.out.println("发送失败， 错误代码=" + msgResult.getErrcode() + ", 错误消息=" + msgResult.getErrmsg());
			}
		} else {
			System.out.println("无法获取数据");
		}
	}
}
